package cn.com.guage.flink;

import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.api.common.functions.RuntimeContext;
import org.apache.flink.configuration.Configuration;

import cn.com.guage.flink.domain.Access;


/**
 * 
* @version:1.0.1
* @Description: 继承RichMapFunction并重写map  open close方法
* @author: yangdechao
* @date: datedate 2021年11月12日 下午3:15:47
 */
public class PKMapFunction extends RichMapFunction<String, Access> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3871984514740021423L;

	@Override
	public Access map(String value) throws Exception {
		System.out.println("------------map---------------");
		String[] splits = value.split(",");
        Long time = Long.valueOf(splits[0].trim());
        String domain = splits[1].trim();
        Double traffic = Double.valueOf(splits[2].trim());
        return new Access(time, domain, traffic);
	}
	@Override
	public void open(Configuration parameters) throws Exception {
		// TODO Auto-generated method stub
		super.open(parameters);
		System.out.println("------------open---------------");
	}

	@Override
	public void close() throws Exception {
		// TODO Auto-generated method stub
		super.close();
		System.out.println("------------close---------------");

	}

	@Override
	public RuntimeContext getRuntimeContext() {
		System.out.println("------------getRuntimeContext---------------");

		// TODO Auto-generated method stub
		return super.getRuntimeContext();
	}

	
}
